import datetime


def is_leap_year(year):
    """
        判断是否闰年
    :param year:
    :return:
    """
    return (year % 4 == 0 and year % 100 != 0) or year % 400 == 0


def get_month_days(month, year=int(datetime.datetime.now().strftime('%Y'))):
    """
        返回月份的天数
    :param month:
    :param year:
    :return:
    """
    if month < 1 or month > 12:
        return 0
    if month == 2:
        return 29 if is_leap_year(year) else 28
    if month in (4, 6, 9, 11):
        return 30
    return 31


print(get_month_days(2,2000))
